package com.ruoyi.web.controller.apilog;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.yanjing.domain.SendDataLog;
import com.ruoyi.yanjing.service.ISendDataLogService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 系统消息推送日志Controller
 * 
 * @author whz
 * @date 2024-12-30
 */
@RestController
@RequestMapping("/yanjing/senddatalog")
public class SendDataLogController extends BaseController
{
    @Autowired
    private ISendDataLogService sendDataLogService;

    /**
     * 查询系统消息推送日志列表
     */
    @PreAuthorize("@ss.hasPermi('yanjing:log:list')")
    @GetMapping("/list")
    public TableDataInfo list(SendDataLog sendDataLog)
    {
        startPage();
        List<SendDataLog> list = sendDataLogService.selectSendDataLogList(sendDataLog);
        return getDataTable(list);
    }

    /**
     * 导出系统消息推送日志列表
     */
    @PreAuthorize("@ss.hasPermi('yanjing:log:export')")
    @Log(title = "系统消息推送日志", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SendDataLog sendDataLog)
    {
        List<SendDataLog> list = sendDataLogService.selectSendDataLogList(sendDataLog);
        ExcelUtil<SendDataLog> util = new ExcelUtil<SendDataLog>(SendDataLog.class);
        util.exportExcel(response, list, "系统消息推送日志数据");
    }

    /**
     * 获取系统消息推送日志详细信息
     */
    @PreAuthorize("@ss.hasPermi('yanjing:log:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(sendDataLogService.selectSendDataLogById(id));
    }

    /**
     * 新增系统消息推送日志
     */
    @PreAuthorize("@ss.hasPermi('yanjing:log:add')")
    @Log(title = "系统消息推送日志", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SendDataLog sendDataLog)
    {
        return toAjax(sendDataLogService.insertSendDataLog(sendDataLog));
    }

    /**
     * 修改系统消息推送日志
     */
    @PreAuthorize("@ss.hasPermi('yanjing:log:edit')")
    @Log(title = "系统消息推送日志", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SendDataLog sendDataLog)
    {
        return toAjax(sendDataLogService.updateSendDataLog(sendDataLog));
    }

    /**
     * 删除系统消息推送日志
     */
    @PreAuthorize("@ss.hasPermi('yanjing:log:remove')")
    @Log(title = "系统消息推送日志", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(sendDataLogService.deleteSendDataLogByIds(ids));
    }
}
